#include "Button.h"

#include <glut.h>
Button::Button(AABB BB)
{
	m_BoundingBox = BB;
}

void Button::Update(Vec2f MousePos)
{
	m_CurrentlyIntersected = m_BoundingBox.Intersects(MousePos);
}

bool Button::IsIntersecting()
{
	return m_CurrentlyIntersected;
}

void Button::Draw()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0, 1280, 0, 720);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushMatrix();
	glLoadIdentity();
	Vec3f* Min = &m_BoundingBox.ReturnMin();
	Vec3f* Max = &m_BoundingBox.ReturnMax();

		glPushMatrix();
				glBegin(GL_QUADS);

			   //Top Left
			   glTexCoord2f(0, 0);
			   glVertex2f(Min->m_x, Max->m_y);
			   
			   //Top Right
			   glTexCoord2f(1, 0);
			   glVertex2f(Max->m_x, Max->m_y);
			   
			   //Bottom Right
			   glTexCoord2f(1, 1);
			   glVertex2f(Max->m_x, Min->m_y);
			   
				//Bottom Left
			   glTexCoord2f(0, 1);
			   glVertex2f(Min->m_x, Min->m_y);

			glEnd();
		glPopMatrix();
}